﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using SharpShare.Afp;
using SharpShare.Configuration;
using SharpShare.Storage;
using System.ComponentModel;

namespace SharpShare.Afp.Configuration {
    public class AfpShareConfigurationElement : ShareElement {
        [Category("AFP Specific")]
        [DisplayName("Time Machine Enabled")]
        [Description("Determines if extensions needed to support Time Machine are enabled on this share.")]
        [TypeConverter(typeof(NaturalBooleanConverter))]
        [ConfigurationProperty("timeMachineEnabled", DefaultValue = false)]
        public bool TimeMachineEnabled {
            get {
                return (bool)this["timeMachineEnabled"];
            }
            set {
                this["timeMachineEnabled"] = value;
            }
        }

        public override void ConfigureService(IShareService service, IStorageProvider storageProvider, IConfigurationContext context) {
            AfpShareSettings settings = ((AfpShareServer)service).GetShareSettings(storageProvider);

            settings.TimeMachineEnabled = this.TimeMachineEnabled;
        }
    }
}
